﻿
@model IList<FCDB.Entity.MyWfProcess>
@{
    ViewBag.Title = "addForm";
    Layout = "~/Views/Shared/_ContentLayout.cshtml";
}
@section HeadIncluder 
{
  <link href='@Url.Content("~/Content/public.css")' rel="stylesheet" />
    <link href='@Url.Content("~/Content/con_style.css")' rel="stylesheet" />

    <script src='@Url.Content("~/Scripts/jquery-1.8.2.min.js")' type="text/javascript" ></script> 
}

@using (Html.BeginForm("SaveMyWorkForm", "WorkFormApply", FormMethod.Post, new { id = "frm" }))
{ 
   <div >
        <div class="dbox_d">
            <table width="100%" class="dbox_con">
                <tr>
                    <td width="100" align="center" colspan="2">
                        <label class="text_s">请选择你需要添加的常用流程：</label>
                    </td>
                </tr>
                @{
    IList<FCDB.Entity.WfProcess> AllWfProcess = (IList<FCDB.Entity.WfProcess>)ViewBag.AllWfProcess;
                }
              @for (int i = 0; i < AllWfProcess.Count - 1; i = i + 2)
              {
                       <tr>
                           <td>
                                <input id="@AllWfProcess[i].ProcessGUID" class="test" type="checkbox"  style="width:20px;" name="test" value ="@AllWfProcess[i].ProcessGUID"> @AllWfProcess[i].ProcessName
                           </td>
                            <td>
                                <input id="@AllWfProcess[i + 1].ProcessGUID" class="test" type="checkbox"  style="width:20px;" name="test" value ="@AllWfProcess[i + 1].ProcessGUID"> @AllWfProcess[i + 1].ProcessName
                           </td>
                       </tr>
              }
              @if (AllWfProcess.Count / 2 != 0)
              {
                  <tr>
                            <td>
                                <input id="@AllWfProcess[AllWfProcess.Count -1].ProcessGUID" class="test" type="checkbox"  style="width:20px;" name="test" value ="@AllWfProcess[AllWfProcess.Count - 1].ProcessGUID"> @AllWfProcess[AllWfProcess.Count - 1].ProcessName
                           </td>
                      <td></td>
                       </tr>
              }
                  @foreach (var i in (IList<FCDB.Entity.MyWfProcess>)ViewBag.MyWfProcess)
                  {
                                <input  class="check" type="checkbox"  style="width:20px; display:none" name="check" value ="@i.ProcessGUID"> 
                  }
            </table>
        </div>
    </div>  
   <div class="btn_d">
        <span class="btn_s btn_c1"><a href="javascript:void(0)" onclick="bnt_reset()" target="_blank">重置</a></span>
        <span class="btn_s btn_c1"><a  href="javascript:void(0)" id="subbtn"  target="_blank">确定</a></span>
        <span class="btn_s btn_c2"><a  href="javascript:void(0)" onclick="cancel()" target="_blank">取消</a></span>
    </div> 
     
    <script src=@Url.Content("/Scripts/jquery.form.js") type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            $('input:checkbox[name="check"]').each(function () {
                var id = "#" + $(this).val();
                $(id).attr("checked", true);
            })
            var check = new Array();
            $("#subbtn").click(function () {
                var model = new Array();
                $('input:checkbox[name="test"]:checked').each(function () {
                    model.push($(this).val());
                })
                var modelString = JSON.stringify(model);
                var saveurl = '@Url.Action("SaveMyWorkForm", "WorkFormApply")';
                $.post(saveurl, { modelString: modelString }, function (data) {
                    var Status = eval('data.Status');
                    var Message = eval('data.Message');
                    if (Status == "2") {
                        alert(Message);
                    }
                    else {
                        window.top.refresh();
                        window.top.oDG.close(Message);
                    }
                });
            });
        });
        function bnt_reset() {
            $("#frm")[0].reset();
        };
        function cancel() {
            window.top.oDG.close();
        };
    </script>
    
}
